/*
@STI LICENSE
(C) 2006-2008 Universit�t Innsbruck.

This file is part of myOntology.

myOntologyis free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

myOntologyis distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with myOntology.  If not, see <http://www.gnu.org/licenses/>.

@STI LICENSE */
/**
 * 
 */
package org.myontology.specialpages;

import java.io.Serializable;

/**
 * @author <a href="michael.hackl@sti2.at">Michael Hackl</a>
 * Project: Myontology - www.myontology.org
 * STI
 *
 * <code>SpecialPage</code> is an instance of a SpecialPage using a SpecialPageConfig
 * it provides everything that is needed for List displaying and paging
 * with init it retrieves the data
 * 
 */
public class SpecialPage extends PageImpl implements Serializable, Pageable{

	/**
	 * 
	 */
	public SpecialPage(SpecialPageConfig config) {
		super(config.getPageSize());
		this.config = config;
	}

	SpecialPageConfig config;
	private int pageId;
	
	/**
	 * initializes the list and retrieves the data
	 * it also initializes the pageId that can be used to track usage of a list
	 */
	public void init() {
		entries = config.execute();
		String pageKey = config.getKey()+System.nanoTime()+Math.random();
		pageId = pageKey.hashCode();
		logger.info("id: "+ pageId +" started SpecialPage with key "+config.getKey()+" "+config.getLabel()+" "+config.getClass().getName());
	}
	
	/**
	 * the pageId should be appended to every link going to an item of the list
	 * so you are able to track the usage of any specific list
	 * @return
	 */
	public int getPageId() {
		return pageId;
	}

	public SpecialPageConfig getConfig() {
		return config;
	}
}
